//
//  HDServiceListVC.m
//  HDWuDaDaoServiceCenter
//
//  Created by HDNiuKuiming on 2017/4/10.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HDServiceListVC.h"
#import "HDServiceCell.h"

@interface HDServiceListVC ()<UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (nonatomic, strong) NSArray *dataArray;
@property (nonatomic, strong) NSArray *imgArray;

@end

@implementation HDServiceListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self collectionViewInit];
}

- (void)collectionViewInit {
    _collectionView.delegate   = self;
    _collectionView.dataSource = self;
    UINib *nib = [UINib nibWithNibName:@"HDServiceCell"
                                bundle: [NSBundle mainBundle]];
    [_collectionView registerNib:nib forCellWithReuseIdentifier:@"HDServiceCell"];
    
    _dataArray = @[@"宣传资料",@"旅游咨询",@"WiFi",@"多媒体查询",@"育婴室",@"急救室",@"雨伞",@"行李寄存"];
    _imgArray = @[@"service_announce",@"service_ask",@"service_WiFi",@"service_multimedia",@"service_baby",@"service_emergency",@"service_umbrella",@"service_luggage"];
}

#pragma mark
#pragma mark collectionView代理方法

//每个section的item个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _imgArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    
    HDServiceCell *cell = (HDServiceCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"HDServiceCell" forIndexPath:indexPath];

    cell.nameLabel.text = _dataArray[indexPath.row];
    cell.imgView.image = [UIImage imageNamed:_imgArray[indexPath.row]];
    cell.backgroundColor = [UIColor clearColor];
    
    return cell;
}

//设置每个item的尺寸
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    CGFloat width = collectionView.frame.size.width/2-20;
    return CGSizeMake(width, width);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backAction:(id)sender {
    [super back];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
